package com.example.config;

import java.util.ArrayList;
import java.util.Map;
import java.sql.ResultSet;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.List;

import java.util.Map;

import java.util.Properties;


import com.example.entity.Test;
import org.apache.ibatis.executor.resultset.ResultSetHandler;

import org.apache.ibatis.plugin.Interceptor;

import org.apache.ibatis.plugin.Intercepts;

import org.apache.ibatis.plugin.Invocation;

import org.apache.ibatis.plugin.Plugin;

import org.apache.ibatis.plugin.Signature;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;


/**
 * @description:
 * @author: zsw
 * @time: 2021/9/1 14:08
 */

@Component
@Intercepts({
        @Signature(type = ResultSetHandler.class,method ="handleResultSets",args= Statement.class)
})

public class ResultSetHandlerPlugin implements Interceptor {
    //拦截目标对象的目标方法的
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("Second:拦截的目标对象"+invocation.getTarget());
        System.out.println(invocation.getMethod());
        System.out.println(invocation.getArgs());
        Object object = invocation.proceed();

        return object;
    }

    //包装目标对象，为目标对象创建代理对象的
    public Object plugin(Object target) {
        System.out.println("将要包装的目标对象" + target);
        return Plugin.wrap(target, this);
    }

    public void setProperties(Properties properties) {
        System.out.println("插件配置的初始化参数" + properties);
    }

}